var Shape = gg.module('shape.Base');

var DataType = {
    parse: function(v) {
        if (v instanceof Shape) {
            return v;
        }
        var type = gg.type(v);
        if (type === 'string') {
            v = JSON.parse(v);
            type = gg.type(v);
        }
        if (type === 'object' && v.classType.substr(0, 6) === 'shape.') {
            return gg.object(v);
        }else{
            gg.error('datatype error');
        }
    }
};

module.exports = DataType;